function [frame] = BGC_plot_map(lon,lat,var)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% THIS FUNCTION PRODUCES A MAP OF A SETAS BGC VARIABLE IN THE DERWENT
% ESTUARY AND RETURNS A FRAME TO CRATE THE ANIMATION
% NOTE MTHAT THIS FUNCTION CALLS SUBFUNCTIONS THAT ARE PART OF M_MAP A 
% FREE MAPPING PACKAGE FOR MATLAB;  HTTP://WWW.EOS.UBC.CA/~RICH/MAP.HTML
%  
% INPUT  : - lon     : SETAS longitude matrix
%          - lat     : SETAS latitude matrix
%          - var     : a SETAS variable. Available options are 'temp' or 
%                     'salt' 
% OUTPUT : - frame   : image frame 
%        
%
% Author: Benedicte Pasquer, IMOS/eMII (http://imos.org.au/)
% email: benedicte.pasquer@utas.edu.au
% May 2013   
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

h = figure('Position',[100 100 900 1500],'Color',[1 1 1]);
% DEFINE THE PROJECTION 
m_proj('mercator','long',[147.00 147.5],'lat',[-43.1 -42.65])
% CREATE THE SURFACE PLOT
m_pcolor(lon,lat,var);shading flat
caxis([0 11]);

% ADD A STANDARD COLORBAR
hh=colorbar('h');
set(get(hh,'title'),'string','Chlorophyll a [mg m-3]','fontsize',11)
set(hh,'Position',[0.2 .30  .30 .03]);

hold on
% ADD  GRID INFORMATION
m_grid('linewi',2,'linest','none','tickdir','out',...
        'fontsize',14,'box','on');
hold off 

title([{'CSIRO SETAS Biogeochemical model : Surface Chlorophyll a'};
    {datestr(time(k)+726834,'mmm dd yyyy')}],... 
    'Fontzise',14)

frame = getframe(h);